package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SendcouService;
import com.ruoyi.system.service.ISendcouServiceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 上门寄件Controller
 * 
 * @author ruoyi
 * @date 2021-06-17
 */
@RestController
@RequestMapping("/system/service/send")
public class SendcouServiceController extends BaseController
{
    @Autowired
    private ISendcouServiceService sendcouServiceService;

    /**
     * 查询上门寄件列表
     */
//    @PreAuthorize("@ss.hasPermi('system:service:list')")
    @GetMapping("/list")
    public TableDataInfo list(SendcouService sendcouService)
    {
        startPage();
        List<SendcouService> list = sendcouServiceService.selectSendcouServiceList(sendcouService);
        return getDataTable(list);
    }

    /**
     * 导出上门寄件列表
     */
//    @PreAuthorize("@ss.hasPermi('system:service:export')")
    @Log(title = "上门寄件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SendcouService sendcouService)
    {
        List<SendcouService> list = sendcouServiceService.selectSendcouServiceList(sendcouService);
        ExcelUtil<SendcouService> util = new ExcelUtil<SendcouService>(SendcouService.class);
        return util.exportExcel(list, "service");
    }

    /**
     * 获取上门寄件详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:service:query')")
    @GetMapping(value = "/{sendId}")
    public AjaxResult getInfo(@PathVariable("sendId") Long sendId)
    {
        return AjaxResult.success(sendcouServiceService.selectSendcouServiceById(sendId));
    }

    /**
     * 新增上门寄件
     */
//    @PreAuthorize("@ss.hasPermi('system:service:add')")
    @Log(title = "上门寄件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SendcouService sendcouService)
    {
        return toAjax(sendcouServiceService.insertSendcouService(sendcouService));
    }

    /**
     * 修改上门寄件
     */
    @PreAuthorize("@ss.hasPermi('system:service:edit')")
    @Log(title = "上门寄件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SendcouService sendcouService)
    {
        return toAjax(sendcouServiceService.updateSendcouService(sendcouService));
    }

    /**
     * 删除上门寄件
     */
    @PreAuthorize("@ss.hasPermi('system:service:remove')")
    @Log(title = "上门寄件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sendIds}")
    public AjaxResult remove(@PathVariable Long[] sendIds)
    {
        return toAjax(sendcouServiceService.deleteSendcouServiceByIds(sendIds));
    }
}
